using System;
using System.Data;
using METU_CMT.DataSets.METUCMTDataSetTableAdapters;

namespace METU_CMT.Business
{
    public class ReviewTeamTableAdapter
    {
        public Team GetReviewerTeam( int reviewTeamId )
        {
            ReviewTeamsTableAdapter _reviewTeamsTableAdapter = new ReviewTeamsTableAdapter(  );
            DataTable _reviewTeam = _reviewTeamsTableAdapter.GetDataByReviewTeamId( reviewTeamId );
            if(_reviewTeam.Rows.Count == 0)
            {
                //TODO: No RT
                return null;
            }

            return new Team( int.Parse( _reviewTeam.Rows[ 0 ][ "RevieverTeamId" ].ToString( ) ) );
        }

        public Team GetReviewedTeam( int reviewTeamId )
        {
            ReviewTeamsTableAdapter _reviewTeamsTableAdapter = new ReviewTeamsTableAdapter();
            DataTable _reviewTeam = _reviewTeamsTableAdapter.GetDataByReviewTeamId(reviewTeamId);
            if (_reviewTeam.Rows.Count == 0)
            {
                //TODO: No RT
                return null;
            }

            return new Team(int.Parse(_reviewTeam.Rows[0]["RevievedTeamId"].ToString()));
        }

        public Event GetEvent( int reviewTeamId )
        {
            ReviewTeamsTableAdapter _reviewTeamsTableAdapter = new ReviewTeamsTableAdapter();
            DataTable _reviewTeam = _reviewTeamsTableAdapter.GetDataByReviewTeamId(reviewTeamId);
            if (_reviewTeam.Rows.Count == 0)
            {
                //TODO: No RT
                return null;
            }

            return new Event( int.Parse( _reviewTeam.Rows[ 0 ][ "EventId" ].ToString( ) ) );
        }
    }
}